//
//  BudgetDatePicker.swift
//  Speek
//
//  Created by MikeHo on 2023/6/30.
//

import SwiftUI

struct BudgetDatePicker: View {
    @Binding var selectYear : String
    @Binding var selectMonth :String
    @State var YearArray = ["2023","2022","2021","2020","2019","2018"]
    @State var MonthArray = ["1","2","3","4","5","6","7","8","9","10","11","12"]
    
    //environment variable
    @Environment(\.dismiss) private var dismiss
    @Environment(\.managedObjectContext) private var context
    
    var body: some View {
            NavigationStack{
                
                HStack{
                    Picker("",selection: $selectYear){
                        ForEach(YearArray,id:\.self){year in
                            Text(year)
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    
                    Picker("",selection: $selectMonth){
                        ForEach(MonthArray,id:\.self){month in
                            Text(month)
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                }
                .toolbar{
                    ToolbarItem(placement: .navigationBarTrailing){
                        Button {
                            // 关闭日期选择界面
                            dismiss()
                        } label: {
                            Text("完成")
                        }
                    }
                }
            }
        
    }
}




